package com.zjt.myjiakao.gdt;

import android.app.Activity;
import android.content.Context;
import android.view.Display;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.Window;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.ImageButton;
import android.widget.LinearLayout;
import com.zjt.myjiakao.R;


public class UtilDialog {
	public static void showWarningDialog(final Context context,String left,String right,String title3,OnDialogOnclikListener listener){
		View view = LayoutInflater.from(context).inflate(R.layout.how_to_use_di_zi_gui_shipin, null);
  		final MyDialog dialog2 = new MyDialog(context, view,R.style.dialog);
  		Window dialogWindow = dialog2.getWindow();
  		WindowManager m; //
  		m = ((Activity)context).getWindowManager(); // 得到屏幕管理器
  		Display d = m.getDefaultDisplay(); // 获取屏幕宽、高用
  		WindowManager.LayoutParams p = dialogWindow.getAttributes(); // 获取对话框当前的参数值
  		// p.height = (int) (d.getHeight() * 0.8); // 高度设置为屏幕的0.6
  		p.width = (int) (d.getWidth() * 0.96); // 宽度设置为屏幕的0.65
  		dialogWindow.setAttributes(p);
  		ImageButton close_image = (ImageButton) view.findViewById(R.id.close_image);
  		close_image.setOnClickListener(new OnClickListener() {
  			@Override
  			public void onClick(View arg0) {
  				// TODO Auto-generated method stub
  				dialog2.dismiss();
  			}
  		});
		Button  title2=view.findViewById(R.id.change_result_head);
		title2.setText(title3);
  		Button about_us = (Button) view.findViewById(R.id.about_us);
  		about_us.setText(left);
  		Button close_button = (Button) view.findViewById(R.id.close_button);
  		about_us.setOnClickListener(new OnClickListener() {
  			@Override
  			public void onClick(View arg0) {
  				// TODO Auto-generated method stub
  				dialog2.dismiss();
  			}
  		});
  		close_button.setText(right);
  		close_button.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
                   listener.confirm();
                   dialog2.dismiss();
			}
		});
  		LinearLayout container = (LinearLayout) view.findViewById(R.id.container);
  		//UtilAd.showCustomAd(container,context);
  		dialog2.setCancelable(false);
  		dialog2.show();
	}

     public static void showExitAppDialog(final Activity context){
		View view = LayoutInflater.from(context).inflate(R.layout.how_to_use_di_zi_gui_shipin, null);
  		final MyDialog dialog2 = new MyDialog(context, view,R.style.dialog);
  		Window dialogWindow = dialog2.getWindow();
  		WindowManager m; //
  		m = ((Activity)context).getWindowManager(); // 得到屏幕管理器
  		Display d = m.getDefaultDisplay(); // 获取屏幕宽、高用
  		WindowManager.LayoutParams p = dialogWindow.getAttributes(); // 获取对话框当前的参数值
  		// p.height = (int) (d.getHeight() * 0.8); // 高度设置为屏幕的0.6
  		p.width = (int) (d.getWidth() * 0.96); // 宽度设置为屏幕的0.65
  		dialogWindow.setAttributes(p);
  		ImageButton close_image = (ImageButton) view.findViewById(R.id.close_image);
  		close_image.setOnClickListener(new OnClickListener() {
  			@Override
  			public void onClick(View arg0) {
  				// TODO Auto-generated method stub
  				dialog2.dismiss();
  			}
  		});
  		Button about_us = (Button) view.findViewById(R.id.about_us);
  		about_us.setText("关  闭");
  		Button close_button = (Button) view.findViewById(R.id.close_button);
  		about_us.setOnClickListener(new OnClickListener() {
  			@Override
  			public void onClick(View arg0) {
  				// TODO Auto-generated method stub
  				dialog2.dismiss();
  			}
  		});
  		close_button.setText("退  出");
  		close_button.setOnClickListener(new OnClickListener() {
  			@Override
  			public void onClick(View arg0) {
  				// TODO Auto-generated method stub
  				dialog2.dismiss();
				context.finish();
  			}
  		});
  		Button change_result_head = (Button) view.findViewById(R.id.change_result_head);
  		change_result_head.setText("确定退出？");
  		LinearLayout container = (LinearLayout) view.findViewById(R.id.container);
  		//UtilAd.showCustomAd(container,context);
  		dialog2.setCancelable(false);
  		dialog2.show();
	}

	
}